package com.crx.springbootinit.controller.user;


import com.crx.springbootinit.annotation.LogApiAnno;
import com.crx.springbootinit.common.BaseResponse;
import com.crx.springbootinit.common.ResultUtils;
import com.crx.springbootinit.model.dto.follow.FollowUserPageDTO;
import com.crx.springbootinit.model.dto.follow.FollowOperationDTO;
import com.crx.springbootinit.model.dto.page.PageQuery;
import com.crx.springbootinit.model.dto.page.PageVO;
import com.crx.springbootinit.model.vo.follow.FollowMeNoticeVO;
import com.crx.springbootinit.model.vo.follow.FansVO;
import com.crx.springbootinit.model.vo.follow.FollowVO;
import com.crx.springbootinit.service.IFollowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 关注表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-10-21
 */
@RequiredArgsConstructor
@Api(tags = "关注模块接口")
@RestController
@RequestMapping("/user/follow")
public class FollowController {

    private final IFollowService followService;

    @ApiOperation("关注或取消关注功能")
    @PostMapping
    @LogApiAnno(title = "关注模块", businessType = "POST")
    public BaseResponse<Void> followOperation(@RequestBody FollowOperationDTO followOperationDTO) {
        followService.followOperation(followOperationDTO);
        return ResultUtils.success();
    }

    @ApiOperation("分页获取关注我的人通知列表")
    @GetMapping("me")
    @LogApiAnno(title = "关注模块", businessType = "GET")
    public BaseResponse<PageVO<FollowMeNoticeVO>> getFollowMeNoticeList(PageQuery pageQuery) {
        PageVO<FollowMeNoticeVO> page =followService.getFollowMeNoticeList(pageQuery);
        return ResultUtils.success(page);
    }

    @ApiOperation("获取关注数量")
    @GetMapping("followCount")
    @LogApiAnno(title = "关注模块", businessType = "GET")
    public BaseResponse<Long> getFollowCount(@RequestHeader String token) {
        Long count = followService.getFollowCount(token);
        return ResultUtils.success(count);
    }
    @ApiOperation("获取关注数量")
    @GetMapping("fansCount")
    @LogApiAnno(title = "关注模块", businessType = "GET")
    public BaseResponse<Long> getFansCount(@RequestHeader String token) {
        Long count = followService.getFansCount(token);
        return ResultUtils.success(count);
    }

    @ApiOperation("分页获取关注列表")
    @GetMapping("followList")
    @LogApiAnno(title = "关注模块", businessType = "GET")
    public BaseResponse<PageVO<FollowVO>> getFollowPage(PageQuery pageQuery){
        PageVO<FollowVO> page=followService.getFollowPage(pageQuery);
        return ResultUtils.success(page);
    }

    @ApiOperation("分页获取粉丝列表")
    @GetMapping("fansList")
    @LogApiAnno(title = "关注模块", businessType = "GET")
    public BaseResponse<PageVO<FansVO>> getFansPage(PageQuery pageQuery){
        PageVO<FansVO> page=followService.getFansPage(pageQuery);
        return ResultUtils.success(page);
    }



}
